*********************
**The Consequences of Partisanship in Economic Perceptions
**Peter K. Enns, Paul M. Kellstedt, & Gregory E. McAvoy
**5/9/12
*********************

**********************************************
**This do file does 3 things.
*1.) Cleans and codes the necessary variables from the ANES Cumulative Data File
	*Note, these commands are commented out.
*2.) Replicates Figure 1 from the text.
	*Note, the actual figure in the text was made in Excel, not Stata
*3.) Tests the equivalence across partisan groups, as reported in the text.
**********************************************

*******************************************
*PART 1:
*Clean data from ANES cumulative file
*******************************************

*keep if VCF0004>=1986 & VCF0004<=2000
*keep VCF0301 VCF0875b

*gen unem = .
*recode unem .=0 if VCF0875b>0 & VCF0875b<998
*recode unem 0=1 if VCF0875b==10

*gen inflation = .
*recode inflation .=0 if VCF0875b>0 & VCF0875b<998
*recode inflation 0=1 if VCF0875b==400

*gen recession = .
*recode recession .=0 if VCF0875b>0 & VCF0875b<998
*recode recession 0=1 if VCF0875b==410

*gen economics = .
*recode economics .=0 if VCF0875b>0 & VCF0875b<998
*recode economics 0=1 if VCF0875b==491
*recode economics 0=1 if VCF0875b==496

***These are the variable descriptions from the ANES Codebook
*010. UNEMPLOYMENT; the number of people with jobs; unemployment
*rate/compensation; job retraining (1974-1986: UNEMPLOYMENT;
*general reference to employment/unemployment; compensation; job
*retraining, etc.) *

*400. INFLATION; rate of inflation; level of prices; cost of living
*(1974-1986: INFLATION; general reference to inflation; high
*prices; high cost of living) *

*410. RECESSION, DEPRESSION; prosperity of the nation; economic
*growth; GNP (1976-1986: RECESSION, DEPRESSION; general
*reference, prosperity of the nation, economic growth) (1974:
*RECESSION, DEPRESSION; general reference) *

*491. Economics--general; "Economics"--NFS [1980] (1974-1978:
*Economics--NFS)
*496. THE ECONOMY--not further specified (code specific mention if R
*clarifies by saying "inflation", etc.; also see #400) [1980]
*[Note: category #496 was added due to the great increase in the
*number of unqualified responses of the "economy." Prior to 1980,
*such non-specific responses (fewer in number) were assumed to be
*references to the inflation problem and were coded as #400]

*gen dem_rep = .
*recode dem_rep .=1 if VCF0301==1
*recode dem_rep .=1 if VCF0301==2
*recode dem_rep .=2 if VCF0301==6
*recode dem_rep .=2 if VCF0301==7

*label define drlbl 1 "1 stg/wk Dem" 2 "2 stg/wk Rep"
*label values dem_rep drlbl

*drop VCF0301 VCF0875b

*save "C:\Users\EKM_POQ_Fig1.dta", replace

*******************************************
**PART 2:
**Generate Figure 1 from the text
*******************************************

*use "C:\Users\EKM_POQ_Fig1.dta"

gen unemdem = unem if dem_rep==1
gen unemrep = unem if dem_rep==2
gen infdem = inflation if dem_rep==1
gen infrep = inflation if dem_rep==2
gen recdem = recession if dem_rep==1
gen recrep = recession if dem_rep==2
gen econdem = economics if dem_rep==1
gen econrep = economics if dem_rep==2

graph bar  recdem recrep  econdem econrep infdem infrep unemdem unemrep, ylabel(0 .05 "5" .1 "1" )

drop unemdem-econrep

*******************************************
**PART 3:
**Test of equivalence across partisan groups
**Note: only the values for unemployment are significant across goups
*******************************************

ttest unem, by(dem_rep)
ttest inflation, by(dem_rep)
ttest recession, by(dem_rep)
ttest economics, by(dem_rep)
